package scoutobahn.highway;

import java.util.Collection;
import java.util.LinkedList;

import scoutobahn.xml.OsmNode;
/**
 * A Town.
 * @author mark
 *
 */
public class Town extends HighwayElement {
    private final OsmNode node;
    /**
     * Constructs a new Town from the given OsmNode.
     * @param townNode The OsmNode
     */
    public Town(final OsmNode townNode) {
        super(townNode, new LinkedList<HighwayElement>());
        this.node = townNode;
    }
    @Override
    public OsmNode getOsmItem() {
        return this.node;
    }
    /**
     * Returns a collection of all parents that are instances of HighwayNode.
     * @return A collection of HighwayNodes
     */
    public Collection<HighwayNode> getNodeParents() {
        LinkedList<HighwayNode> nodes = new LinkedList<HighwayNode>();
        for (HighwayElement element : super.getParents()) {
            if (element instanceof HighwayNode) {
                nodes.add((HighwayNode) element);
            }
        }
        return nodes;
    }
}
